home *** CD-ROM | disk | FTP | other *** search
/ PC Player 2004 May / pc player 2004-05.iso / Demos / FarCry / Data1.cab / _96549365B0FE405A808883D9437116F2 < prev    next >
Encoding:
Text File  |  2004-01-06  |  3.6 KB  |  108 lines

  1. -- look in microscope
  2. -- Created 2002-12-03 Amanda
  3.  
  4. -- to do work out how to find out first behaviour
  5. --------------------------
  6. AIBehaviour.Job_Microscope = {
  7.     Name = "Job_Microscope",
  8.     JOB = 1,
  9.     AnimTable ={
  10.         [AIAnchor.AIANCHOR_MICROSCOPE]= {"microscope1","microscope2"},
  11.         },
  12.     TargetType = AIAnchor.AIANCHOR_MICROSCOPE,
  13.     --------------------------
  14.     OnSpawn = function(self,entity)    
  15.         self:FIND_ANCHOR(entity);    
  16.     end,
  17.     ------------------------------------------------------------------------     
  18.     OnNoTarget = function(self,entity)    
  19.     end,
  20.     ------------------------------------------------------------------------     
  21.     OnJobExit = function( self, entity )
  22.     -- make sure doesnt leave job with no gun
  23.         entity.cnt.AnimationSystemEnabled = 1;
  24.         AIBehaviour.DEFAULT:UNHIDE_GUN(entity,sender);
  25.         entity:InsertSubpipe(0,"force_reevaluate");        
  26.     end,
  27.     ------------------------------------------------------------------------     
  28.      OnBored = function(self,entity)    
  29.          rnd = random(1,2);
  30.         if (rnd == 1) then
  31.             entity.cnt.AnimationSystemEnabled = 1;
  32.             entity:InsertSubpipe(0,"pause");
  33.             local boredAnchor = AI_BoredManager:FindAnchor(entity,AI_BoredManager.AIBORED_SCIENTIST,10);
  34.             if (boredAnchor) then
  35.                 AI:Signal(0,1, boredAnchor.signal,entity.id);
  36.                 entity.EventToCall = "OnSpawn";
  37.             end
  38.         else
  39.             entity:MakeRandomConversation();
  40.         end
  41.     end,
  42.     ------------------------------------------------------------------------     
  43.     FIND_ANCHOR = function (self,entity)
  44.         
  45.         --locate anchor of desired type
  46.         local foundObject = AI:FindObjectOfType(entity.id,20,self.TargetType);
  47.          if ( foundObject ) then
  48.              entity:SelectPipe(0,"anchor_loop_devalue",foundObject);
  49.         else
  50.             if (entity.Properties.aibehavior_behaviour == "Job_Microscope") then
  51.                 entity:SelectPipe(0,"beat");
  52.                 self:Idle(entity,sender);
  53.             else
  54.                 entity:SelectPipe(0,"beat");
  55.                  AI:Signal(0,1, "BackToJob",entity.id);
  56.                  if (entity.Properties.aibehavior_behaviour =="Job_CheckApparatus") then
  57.                      entity.EventToCall = "MARKOFF_CLIPBOARD";
  58.                  else
  59.                      entity.EventToCall = "OnSpawn";
  60.                  end
  61.             end
  62.         end    
  63.     end,
  64.     ------------------------------------------------------------------------     
  65.     Idle = function (self, entity, sender)
  66.         entity.cnt.AnimationSystemEnabled = 0;
  67.         local MyAnim = Mutant_IdleManager:GetIdle(entity);
  68.             -----    
  69.             AI:CreateGoalPipe(MyAnim.Name.."Delay");
  70.             AI:PushGoal(MyAnim.Name.."Delay","timeout",1,MyAnim.duration);
  71.             AI:PushGoal(MyAnim.Name.."Delay","signal",0,1,"FIND_ANCHOR",0);
  72.             -----
  73.         entity:StartAnimation(0,MyAnim.Name);                            
  74.         entity:SelectPipe(0,MyAnim.Name.."Delay");
  75.  
  76.     end,    
  77.     ------------------------------------------------------------------------     
  78.     MAIN = function (self, entity, sender)
  79.         local choices = getn(self.AnimTable[self.TargetType]);
  80.         local anim = self.AnimTable[self.TargetType][random(1,choices)] 
  81.         entity:StartAnimation(0,anim);
  82.     end,
  83.     ---------------------------------------------
  84.     DECISION_POINT = function( self,entity , sender)
  85.     
  86.          local rnd = random(1,10);
  87.          
  88.          --occasionaly decide enough with button pressing go back to real job
  89.         if ( rnd < 4) then 
  90.             if (entity.Properties.aibehavior_behaviour ==  "Job_Microscope") then
  91.                 self:Idle(entity,sender);
  92.             else
  93.                  AI:Signal(0,1, "BackToJob",entity.id);
  94.                  if (entity.Properties.aibehavior_behaviour =="Job_CheckApparatus") then
  95.                      entity.EventToCall = "MARKOFF_CLIPBOARD";
  96.                  else
  97.                      entity.EventToCall = "OnSpawn";
  98.                  end
  99.             end
  100. --        -- or an idle animation    
  101.         elseif (rnd>8) then    
  102.             self:Idle(entity,sender);        
  103.         end
  104.     end,
  105.     ---------------------------------------------            
  106. }
  107.  
  108.